<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const p1 = () =>
      new Promise((resolve, reject) => {
        console.log(1)
        let p2 = new Promise((resolve, reject) => {
          console.log(2)
          setTimeout(() => {
            console.log(3)
            resolve(4)
          }, 0)
          resolve(5)
        })
        resolve(6)
        p2.then((arg) => {
          console.log(arg)
        })
      })

    setTimeout(() => {
      console.log(8)
      const p3 = new Promise((reject) => {
        reject(9)
      }).then((res) => {
        console.log(res)
      })
    }, 0)

    p1().then((arg) => {
      console.log(arg)
    })

    console.log(10)
  </script>
</body>

</html>